How to find sum of diagonal elements in java